package com.lc.SlidingPaneUnit;

import com.example.japaneseapp.R;
import com.example.japaneseapp.R.layout;
import com.lc.SlidingPaneUnit.UnitFragment.UnitChangeListener;

import android.app.Activity;
import android.app.ActionBar;
import android.app.Fragment;
import android.os.Bundle;
import android.support.v4.widget.SlidingPaneLayout;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.os.Build;

public class SlidingPaneUnitActivity extends Activity  implements UnitChangeListener{
	private SlidingPaneLayout pane;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_sliding_pane_unit);
		pane = (SlidingPaneLayout) findViewById(R.id.sp);
		pane.setPanelSlideListener(new PaneListener());
	}

	private class PaneListener implements SlidingPaneLayout.PanelSlideListener {

		@Override
		public void onPanelClosed(View view) {

			getFragmentManager().findFragmentById(R.id.leftpane)
					.setHasOptionsMenu(false);
			getFragmentManager().findFragmentById(R.id.rightpane)
					.setHasOptionsMenu(true);
		}

		@Override
		public void onPanelOpened(View view) {
			getFragmentManager().findFragmentById(R.id.leftpane)
					.setHasOptionsMenu(true);
			getFragmentManager().findFragmentById(R.id.rightpane)
					.setHasOptionsMenu(false);
		}

		@Override
		public void onPanelSlide(View view, float arg1) {
		}

	}

	@Override
	public void onChangeUnit(int idUnit) {
		WordFragment wordFragment = (WordFragment) getFragmentManager().findFragmentById(R.id.rightpane);
		wordFragment.setUnit(idUnit);
		
	}
	

}
